package renpyas3.view.components 
{
	import flash.display.DisplayObject;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	/**
	 * extend buttons to store label to jump to
	 */
	public class MenuChoiceButton extends SimpleButton
	{
		private var _nextInstructionIndex:uint;
		private var _buttonWidth:Number;

		public function MenuChoiceButton(label:String = "", nextInstructionIndex:uint =0 , buttonWidth:Number=700) 
		{
			_nextInstructionIndex = nextInstructionIndex;
			_buttonWidth = buttonWidth;
			
			//create upState
			var newUpState:Sprite = new Sprite();
			newUpState.graphics.beginFill(0x000000);
			newUpState.graphics.lineStyle(3, 0xFFFFFF);
			newUpState.graphics.drawRoundRect(-buttonWidth/2,0,_buttonWidth, 30, 20, 20);
			newUpState.graphics.endFill();
			
			//add upState text
			var newUpStateText:TextField = new TextField();
			newUpStateText.width = _buttonWidth;
			newUpStateText.height = 30;
			newUpStateText.defaultTextFormat = new TextFormat("Verdana", 20, 0xFFFFFF,null,null,null,null,null,TextFormatAlign.CENTER);
			newUpStateText.text = label;
			newUpState.addChild(newUpStateText);
			newUpStateText.x = -buttonWidth/2;
			newUpStateText.y = 1;

			//create overState
			var newOverState:Sprite = new Sprite();
			newOverState.graphics.beginFill(0x222222);
			newOverState.graphics.lineStyle(3, 0xEEEEEE);
			newOverState.graphics.drawRoundRect(-buttonWidth/2,0, _buttonWidth, 30, 20, 20);
			newOverState.graphics.endFill();
			
			//add overState text
			var newOverStateText:TextField = new TextField();
			newOverStateText.width = _buttonWidth;
			newOverStateText.height = 30;
			newOverStateText.defaultTextFormat = new TextFormat("Verdana", 20, 0xEEEEEE,null,null,null,null,null,TextFormatAlign.CENTER);
			newOverStateText.text = label;
			newOverState.addChild(newOverStateText);
			newOverStateText.x = -buttonWidth/2;
			newOverStateText.y = 1;
			
			//hit area
			var newHitState:Sprite = new Sprite();
			newHitState.graphics.beginFill(0x111111);
			newHitState.graphics.drawRoundRect(-buttonWidth/2,0, _buttonWidth, 30, 20, 20);
			newHitState.graphics.endFill();

			super(newUpState,newOverState,null,newHitState);
		}
		
		public function get nextInstructionIndex():uint { return _nextInstructionIndex; }
		
	}
}